package com.action;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bean.InstrumentBean;
import com.bean.RecordBean;
import com.bean.UserBean;
import com.dao.StatisticDao;
import com.exception.DBException;
import com.exception.StatisticException;

public class StatisticAction
{

	public void getTopTen(HttpServletRequest request,
			HttpServletResponse response) throws DBException,
			StatisticException
	{
		StatisticDao sd = new StatisticDao();
		ArrayList<RecordBean> list = sd.getTopTen();

		request.setAttribute("topList", list);
		try
		{
			request.getRequestDispatcher("/lab_admin/statistic_Top.jsp").forward(
					request, response);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		
	}

	public void getIn(HttpServletRequest request,
			HttpServletResponse response) throws DBException,
			StatisticException
	{
		StatisticDao sd = new StatisticDao();
		ArrayList<InstrumentBean> list = sd.getIn();

		request.setAttribute("inList", list);
		try
		{
			request.getRequestDispatcher("/lab_admin/statistic_InsIn.jsp").forward(
					request, response);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}

	public void getOut(HttpServletRequest request,
			HttpServletResponse response) throws DBException,
			StatisticException
	{
		StatisticDao sd = new StatisticDao();
		ArrayList<RecordBean> list = sd.getOut();

		request.setAttribute("outList", list);
		try
		{
			request.getRequestDispatcher("/lab_admin/statistic_InsOut.jsp").forward(
					request, response);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}

	public void getAllTools(HttpServletRequest request,
			HttpServletResponse response) throws DBException,
			StatisticException
	{
		StatisticDao sd = new StatisticDao();
		ArrayList<InstrumentBean> list = sd.getAllIns();

		request.setAttribute("toolList", list);
		try
		{
			request.getRequestDispatcher("/lab_admin/statistic_AllIns.jsp").forward(
					request, response);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}

	public void getAllUsers(HttpServletRequest request,
			HttpServletResponse response) throws DBException,
			StatisticException
	{
		StatisticDao sd = new StatisticDao();
		ArrayList<UserBean> list = sd.getAllUsers();

		request.setAttribute("userList", list);
		try
		{
			request.getRequestDispatcher("/lab_admin/statistic_AllUser.jsp").forward(
					request, response);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
}
